package com.btsi.bcos.biz.dac.contacts;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.codec.datatypes.Address;
import org.fisco.bcos.sdk.v3.codec.datatypes.Bool;
import org.fisco.bcos.sdk.v3.codec.datatypes.Event;
import org.fisco.bcos.sdk.v3.codec.datatypes.Function;
import org.fisco.bcos.sdk.v3.codec.datatypes.Type;
import org.fisco.bcos.sdk.v3.codec.datatypes.TypeReference;
import org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.tuples.generated.Tuple1;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.tuples.generated.Tuple7;
import org.fisco.bcos.sdk.v3.contract.Contract;
import org.fisco.bcos.sdk.v3.crypto.CryptoSuite;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.model.CryptoType;
import org.fisco.bcos.sdk.v3.model.TransactionReceipt;
import org.fisco.bcos.sdk.v3.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.v3.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class EvidencePreservation extends Contract {
    public static final String[] BINARY_ARRAY = {"6080604052600160655534801561001557600080fd5b506111f3806100256000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80636c7f15421161008c5780638da5cb5b116100665780638da5cb5b146101ad578063abcdf188146101be578063e2f31829146101e1578063f2fde38b146101f457600080fd5b80636c7f15421461018a578063715018a61461019d5780638129fc1c146101a557600080fd5b806322c26da5146100d45780632b89cee0146100e95780634997621914610118578063586e05a514610139578063589a17431461014c57806358e77fe914610177575b600080fd5b6100e76100e2366004610e48565b610207565b005b6100fc6100f7366004610e6a565b610286565b60405161010f9796959493929190610ed0565b60405180910390f35b61012b610126366004610f79565b61049e565b60405190815260200161010f565b61012b610147366004610e6a565b610676565b61015f61015a366004610e6a565b6106a8565b6040516001600160a01b03909116815260200161010f565b61012b610185366004610e48565b6106f1565b61012b610198366004610e6a565b61075e565b6100e7610790565b6100e7610804565b6033546001600160a01b031661015f565b6101d16101cc366004610e48565b610882565b604051901515815260200161010f565b6100e76101ef366004610e48565b6108c4565b6100e761020236600461103c565b610981565b6033546001600160a01b0316331461023a5760405162461bcd60e51b81526004016102319061106c565b60405180910390fd5b600082815260696020526040902080546102665760405162461bcd60e51b8152600401610231906110a1565b60008381526068602052604090205461028190849084610a6c565b505050565b6000818152606960205260408120805460609291829184918391839183916102c05760405162461bcd60e51b8152600401610231906110a1565b80600101816002015482600301548360040184600501548560060186600701548680546102ec906110c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610318906110c4565b80156103655780601f1061033a57610100808354040283529160200191610365565b820191906000526020600020905b81548152906001019060200180831161034857829003601f168201915b50505050509650838054610378906110c4565b80601f01602080910402602001604051908101604052809291908181526020018280546103a4906110c4565b80156103f15780601f106103c6576101008083540402835291602001916103f1565b820191906000526020600020905b8154815290600101906020018083116103d457829003601f168201915b50505050509350818054610404906110c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610430906110c4565b801561047d5780601f106104525761010080835404028352916020019161047d565b820191906000526020600020905b81548152906001019060200180831161046057829003601f168201915b50505050509150975097509750975097509750975050919395979092949650565b60008a6104bd5760405162461bcd60e51b8152600401610231906110ff565b600060655490506040518061010001604052808281526020018c8c8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509082525060208082018c905260408083018c90528051601f8b01839004830281018301909152898152606090920191908a908a9081908401838280828437600092019190915250505090825250602080820188905260408051601f8801839004830281018301825287815292019190879087908190840183828082843760009201829052509385525050426020938401525083815260698252604090208251815582820151805191926105c692600185019290910190610daf565b506040820151600282015560608201516003820155608082015180516105f6916004840191602090910190610daf565b5060a0820151600582015560c0820151805161061c916006840191602090910190610daf565b5060e082015181600701559050506106348c82610b11565b6106408160008e610a6c565b600081815260676020526040902080546001600160a01b031916331790556065805460010190559b9a5050505050505050505050565b6000816106955760405162461bcd60e51b8152600401610231906110ff565b506000908152606a602052604090205490565b600081815260696020526040812080546106d45760405162461bcd60e51b8152600401610231906110a1565b50506000908152606760205260409020546001600160a01b031690565b60006106fc8361075e565b82106107405760405162461bcd60e51b8152602060048201526013602482015272696e646578206f7574206f6620626f756e647360681b6044820152606401610231565b506000918252606b6020908152604080842092845291905290205490565b60008161077d5760405162461bcd60e51b8152600401610231906110ff565b5060009081526066602052604090205490565b6033546001600160a01b031633146107ba5760405162461bcd60e51b81526004016102319061106c565b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b600054610100900460ff16806108195750303b155b80610827575060005460ff16155b6108435760405162461bcd60e51b815260040161023190611127565b600054610100900460ff16158015610865576000805461ffff19166101011790555b61086d610b74565b801561087f576000805461ff00191690555b50565b600082815260696020526040812080546108ae5760405162461bcd60e51b8152600401610231906110a1565b5050600091825260686020526040909120541490565b600082815260696020526040902080546108f05760405162461bcd60e51b8152600401610231906110a1565b336108fa846106a8565b6001600160a01b0316146109405760405162461bcd60e51b815260206004820152600d60248201526c1858d8d95cdcc819195b9a5959609a1b6044820152606401610231565b6005810182905560405182815283907ffa0d8fb4df0f79629245eaa9486090d9ea8261b2144243aa913132b1d8f6407a9060200160405180910390a2505050565b6033546001600160a01b031633146109ab5760405162461bcd60e51b81526004016102319061106c565b6001600160a01b038116610a105760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610231565b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b8115610a8957600082815260666020526040902080546000190190555b8015610aa5576000818152606660205260409020805460010190555b6000838152606860205260409020819055818114610add578115610acd57610acd8284610be5565b8015610add57610add8184610b11565b8082847f280d479074269f29633634d3a631f9998bb99d5b6341c5dcb9ef19d2aafe4bff60405160405180910390a4505050565b60006001610b1e8461075e565b610b28919061118b565b6000848152606b602090815260408083208484528252808320869055858352606c8252808320849055868352606a9091528120805492935090610b6a836111a2565b9190505550505050565b600054610100900460ff1680610b895750303b155b80610b97575060005460ff16155b610bb35760405162461bcd60e51b815260040161023190611127565b600054610100900460ff16158015610bd5576000805461ffff19166101011790555b610bdd610c83565b61086d610cf7565b6000610bf08361075e565b6000838152606c6020526040902054909150808214610c39576000848152606b602090815260408083208584528252808320548484528184208190558352606c90915290208190555b6000838152606c60209081526040808320839055868352606b82528083208584528252808320839055868352606a9091528120805491610c78836111a2565b919050555050505050565b600054610100900460ff1680610c985750303b155b80610ca6575060005460ff16155b610cc25760405162461bcd60e51b815260040161023190611127565b600054610100900460ff1615801561086d576000805461ffff1916610101179055801561087f576000805461ff001916905550565b600054610100900460ff1680610d0c5750303b155b80610d1a575060005460ff16155b610d365760405162461bcd60e51b815260040161023190611127565b600054610100900460ff16158015610d58576000805461ffff19166101011790555b603380546001600160a01b0319163390811790915560405181906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350801561087f576000805461ff001916905550565b828054610dbb906110c4565b90600052602060002090601f016020900481019282610ddd5760008555610e23565b82601f10610df657805160ff1916838001178555610e23565b82800160010185558215610e23579182015b82811115610e23578251825591602001919060010190610e08565b50610e2f929150610e33565b5090565b5b80821115610e2f5760008155600101610e34565b60008060408385031215610e5b57600080fd5b50508035926020909101359150565b600060208284031215610e7c57600080fd5b5035919050565b6000815180845260005b81811015610ea957602081850181015186830182015201610e8d565b81811115610ebb576000602083870101525b50601f01601f19169290920160200192915050565b60e081526000610ee360e083018a610e83565b8860208401528760408401528281036060840152610f018188610e83565b905085608084015282810360a0840152610f1b8186610e83565b9150508260c083015298975050505050505050565b60008083601f840112610f4257600080fd5b50813567ffffffffffffffff811115610f5a57600080fd5b602083019150836020828501011115610f7257600080fd5b9250929050565b60008060008060008060008060008060e08b8d031215610f9857600080fd5b8a35995060208b013567ffffffffffffffff80821115610fb757600080fd5b610fc38e838f01610f30565b909b50995060408d0135985060608d0135975060808d01","35915080821115610fea57600080fd5b610ff68e838f01610f30565b909750955060a08d0135945060c08d013591508082111561101657600080fd5b506110238d828e01610f30565b915080935050809150509295989b9194979a5092959850565b60006020828403121561104e57600080fd5b81356001600160a01b038116811461106557600080fd5b9392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600990820152681b9bdd08199bdd5b9960ba1b604082015260600190565b600181811c908216806110d857607f821691505b602082108114156110f957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600e908201526d1bdddb995c881c995c5d5a5c995960921b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008282101561119d5761119d611175565b500390565b60006000198214156111b6576111b6611175565b506001019056fea26469706673582212200956d6a58d82f4a5f684a73839cb38f512b1ac0314f98904bf94225cd11ec24c64736f6c634300080b0033"};

    public static final String BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {"6080604052600160655534801561001557600080fd5b506111fd806100256000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063995833511161008c578063d86e29e211610066578063d86e29e2146101c9578063ea0a4244146101d1578063ea605f3d146101e4578063f76d1540146101ec57600080fd5b8063995833511461017d578063a8882ebb146101a3578063ac02e959146101b657600080fd5b806307937a72146100d457806316cad12a146100fa57806333c4b4951461010f57806343c96658146101225780635089e2c8146101455780638f1b55f71461016a575b600080fd5b6100e76100e2366004610e9b565b6101ff565b6040519081526020015b60405180910390f35b61010d610108366004610f5e565b6103e1565b005b61010d61011d366004610f8e565b6104ce565b610135610130366004610f8e565b61058d565b60405190151581526020016100f1565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016100f1565b6100e7610178366004610f8e565b6105d0565b61019061018b366004610fb0565b61063e565b6040516100f19796959493929190611016565b6100e76101b1366004610fb0565b610857565b61010d6101c4366004610f8e565b61088a565b61010d610902565b6101526101df366004610fb0565b610977565b61010d6109c1565b6100e76101fa366004610fb0565b610a40565b60008a61022857604051636381e58960e11b815260040161021f90611076565b60405180910390fd5b600060655490506040518061010001604052808281526020018c8c8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509082525060208082018c905260408083018c90528051601f8b01839004830281018301909152898152606090920191908a908a9081908401838280828437600092019190915250505090825250602080820188905260408051601f88018390048302810183018252878152920191908790879081908401838280828437600092018290525093855250504260209384015250838152606982526040902082518155828201518051919261033192600185019290910190610db9565b50604082015160028201556060820151600382015560808201518051610361916004840191602090910190610db9565b5060a0820151600582015560c08201518051610387916006840191602090910190610db9565b5060e0820151816007015590505061039f8c82610a73565b6103ab8160008e610ad6565b600081815260676020526040902080546001600160a01b031916331790556065805460010190559b9a5050505050505050505050565b6033546001600160a01b0316331461040c57604051636381e58960e11b815260040161021f9061109e565b6001600160a01b03811661047257604051636381e58960e11b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161021f565b6033546040516001600160a01b038084169216907f5c7c30d4a0f08950cb23be4132957b357fa5dfdb0fcf218f81b86a1c036e47d090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b600082815260696020526040902080546104fb57604051636381e58960e11b815260040161021f906110d3565b3361050584610977565b6001600160a01b03161461054c57604051636381e58960e11b815260206004820152600d60248201526c1858d8d95cdcc819195b9a5959609a1b604482015260640161021f565b6005810182905560405182815283907f3f037324cf7b2d6bc2afabf8a0a5f740f0282121bf189b9de88ac78de0b7b1709060200160405180910390a2505050565b600082815260696020526040812080546105ba57604051636381e58960e11b815260040161021f906110d3565b5050600091825260686020526040909120541490565b60006105db83610a40565b821061062057604051636381e58960e11b8152602060048201526013602482015272696e646578206f7574206f6620626f756e647360681b604482015260640161021f565b506000918252606b6020908152604080842092845291905290205490565b60008181526069602052604081208054606092918291849183918391839161067957604051636381e58960e11b815260040161021f906110d3565b80600101816002015482600301548360040184600501548560060186600701548680546106a5906110f6565b80601f01602080910402602001604051908101604052809291908181526020018280546106d1906110f6565b801561071e5780601f106106f35761010080835404028352916020019161071e565b820191906000526020600020905b81548152906001019060200180831161070157829003601f168201915b50505050509650838054610731906110f6565b80601f016020809104026020016040519081016040528092919081815260200182805461075d906110f6565b80156107aa5780601f1061077f576101008083540402835291602001916107aa565b820191906000526020600020905b81548152906001019060200180831161078d57829003601f168201915b505050505093508180546107bd906110f6565b80601f01602080910402602001604051908101604052809291908181526020018280546107e9906110f6565b80156108365780601f1061080b57610100808354040283529160200191610836565b820191906000526020600020905b81548152906001019060200180831161081957829003601f168201915b50505050509150975097509750975097509750975050919395979092949650565b60008161087757604051636381e58960e11b815260040161021f90611076565b506000908152606a602052604090205490565b6033546001600160a01b031633146108b557604051636381e58960e11b815260040161021f9061109e565b600082815260696020526040902080546108e257604051636381e58960e11b815260040161021f906110d3565b6000838152606860205260409020546108fd90849084610ad6565b505050565b6033546001600160a01b0316331461092d57604051636381e58960e11b815260040161021f9061109e565b6033546040516000916001600160a01b0316907f5c7c30d4a0f08950cb23be4132957b357fa5dfdb0fcf218f81b86a1c036e47d0908390a3603380546001600160a01b0319169055565b600081815260696020526040812080546109a457604051636381e58960e11b815260040161021f906110d3565b50506000908152606760205260409020546001600160a01b031690565b600054610100900460ff16806109d65750303b155b806109e4575060005460ff16155b610a0157604051636381e58960e11b815260040161021f90611131565b600054610100900460ff16158015610a23576000805461ffff19166101011790555b610a2b610b7b565b8015610a3d576000805461ff00191690555b50565b600081610a6057604051636381e58960e11b815260040161021f90611076565b5060009081526066602052604090205490565b60006001610a8084610a40565b610a8a9190611195565b6000848152606b602090815260408083208484528252808320869055858352606c8252808320849055868352606a9091528120805492935090610acc836111ac565b9190505550505050565b8115610af357600082815260666020526040902080546000190190555b8015610b0f576000818152606660205260409020805460010190555b6000838152606860205260409020819055818114610b47578115610b3757610b378284610bed565b8015610b4757610b478184610a73565b8082847ff3f5d0a01084e7ce0e90224f2d5fd2bedc428d37717188de21c5433b1d07846260405160405180910390a4505050565b600054610100900460ff1680610b905750303b155b80610b9e575060005460ff16155b610bbb57604051636381e58960e11b815260040161021f90611131565b600054610100900460ff16158015610bdd576000805461ffff19166101011790555b610be5610c8b565b610a2b610d00565b6000610bf883610a40565b6000838152606c6020526040902054909150808214610c41576000848152606b602090815260408083208584528252808320548484528184208190558352606c90915290208190555b6000838152606c60209081526040808320839055868352606b82528083208584528252808320839055868352606a9091528120805491610c80836111ac565b919050555050505050565b600054610100900460ff1680610ca05750303b155b80610cae575060005460ff16155b610ccb57604051636381e58960e11b815260040161021f90611131565b600054610100900460ff16158015610a2b576000805461ffff19166101011790558015610a3d576000805461ff001916905550565b600054610100900460ff1680610d155750303b155b80610d23575060005460ff16155b610d4057604051636381e58960e11b815260040161021f90611131565b600054610100900460ff16158015610d62576000805461ffff19166101011790555b603380546001600160a01b0319163390811790915560405181906000907f5c7c30d4a0f08950cb23be4132957b357fa5dfdb0fcf218f81b86a1c036e47d0908290a3508015610a3d576000805461ff001916905550565b828054610dc5906110f6565b90600052602060002090601f016020900481019282610de75760008555610e2d565b82601f10610e0057805160ff1916838001178555610e2d565b82800160010185558215610e2d579182015b82811115610e2d578251825591602001919060010190610e12565b50610e39929150610e3d565b5090565b5b80821115610e395760008155600101610e3e565b60008083601f840112610e6457600080fd5b50813567ffffffffffffffff811115610e7c57600080fd5b602083019150836020828501011115610e9457600080fd5b9250929050565b60008060008060008060008060008060e08b8d031215610eba57600080fd5b8a35995060208b013567ffffffffffffffff80821115610ed957600080fd5b610ee58e838f01610e52565b909b50995060408d0135985060608d0135975060808d0135915080821115610f0c57600080fd5b610f188e838f01610e52565b909750955060a08d0135945060c08d0135915080821115610f3857600080fd5b50610f458d828e01610e52565b915080935050809150509295989b9194979a5092959850565b600060208284031215610f7057600080fd5b81356001600160a01b0381168114610f8757600080fd5b9392505050565b60008060408385031215610fa157600080fd5b50508035926020909101359150565b600060208284031215610fc257600080fd5b5035919050565b6000815180845260005b81811015610fef","57602081850181015186830182015201610fd3565b81811115611001576000602083870101525b50601f01601f19169290920160200192915050565b60e08152600061102960e083018a610fc9565b88602084015287604084015282810360608401526110478188610fc9565b905085608084015282810360a08401526110618186610fc9565b9150508260c083015298975050505050505050565b6020808252600e908201526d1bdddb995c881c995c5d5a5c995960921b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600990820152681b9bdd08199bdd5b9960ba1b604082015260600190565b600181811c9082168061110a57607f821691505b6020821081141561112b5763b95aa35560e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b63b95aa35560e01b600052601160045260246000fd5b6000828210156111a7576111a761117f565b500390565b60006000198214156111c0576111c061117f565b506001019056fea264697066735822122043dc10aabdbcc1efa0861ca2a39f75c3b4fa240f202784ddcd489d091d15a34d64736f6c634300080b0033"};

    public static final String SM_BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"from\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"to\",\"type\":\"bytes32\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"status\",\"type\":\"uint256\"}],\"name\":\"UpdateStatus\",\"type\":\"event\"},{\"conflictFields\":[{\"kind\":3,\"slot\":102,\"value\":[0]}],\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"owner\",\"type\":\"bytes32\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"selector\":[1820267842,4151121216],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":0},{\"kind\":3,\"slot\":102,\"value\":[0]},{\"kind\":3,\"slot\":106,\"value\":[0]},{\"kind\":3,\"slot\":107,\"value\":[0]},{\"kind\":4,\"value\":[101]}],\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"owner\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"org\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"category\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"code\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"status\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"metadata\",\"type\":\"string\"}],\"name\":\"create\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"selector\":[1234657817,127105650],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":3,\"slot\":103,\"value\":[0]},{\"kind\":3,\"slot\":105,\"value\":[0]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"}],\"name\":\"creatorOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"selector\":[1486493507,3926540868],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":3,\"slot\":105,\"value\":[0]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"}],\"name\":\"evidenceById\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"org\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"category\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"code\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"status\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"metadata\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"createTime\",\"type\":\"uint256\"}],\"selector\":[730451680,2572694353],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":3,\"slot\":102,\"value\":[0]},{\"kind\":3,\"slot\":107,\"value\":[0]},{\"kind\":3,\"slot\":107,\"value\":[1]}],\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"owner\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"evidenceIdByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"selector\":[1491566569,2400933367],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[0]},{\"kind\":4,\"value\":[51]}],\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"selector\":[2167012380,3932184381],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":3,\"slot\":104,\"value\":[0]},{\"kind\":3,\"slot\":105,\"value\":[0]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"owner\",\"type\":\"bytes32\"}],\"name\":\"isOwnedBy\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"selector\":[2882400648,1137272408],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[51]}],\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"selector\":[2376452955,1351213768],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[51]}],\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"selector\":[1901074598,3631098338],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":0},{\"kind\":3,\"slot\":102,\"value\":[1]},{\"kind\":3,\"slot\":104,\"value\":[0]},{\"kind\":3,\"slot\":105,\"value\":[0]},{\"kind\":3,\"slot\":108,\"value\":[0]},{\"kind\":4,\"value\":[51]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"newOwner\",\"type\":\"bytes32\"}],\"name\":\"transfer\",\"outputs\":[],\"selector\":[583167397,2885871961],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[51]}],\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"selector\":[4076725131,382390570],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":3,\"slot\":103,\"value\":[0]},{\"kind\":3,\"slot\":105,\"value\":[0]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"evidenceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"newStatus\",\"type\":\"uint256\"}],\"name\":\"updateStatus\",\"outputs\":[],\"selector\":[3807582249,868529301],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":3,\"slot\":106,\"value\":[0]}],\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"owner\",\"type\":\"bytes32\"}],\"name\":\"versionOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"selector\":[1483605413,2827497147],\"stateMutability\":\"view\",\"type\":\"function\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_BALANCEOF = "balanceOf";

    public static final String FUNC_CREATE = "create";

    public static final String FUNC_CREATOROF = "creatorOf";

    public static final String FUNC_EVIDENCEBYID = "evidenceById";

    public static final String FUNC_EVIDENCEIDBYINDEX = "evidenceIdByIndex";

    public static final String FUNC_INITIALIZE = "initialize";

    public static final String FUNC_ISOWNEDBY = "isOwnedBy";

    public static final String FUNC_OWNER = "owner";

    public static final String FUNC_RENOUNCEOWNERSHIP = "renounceOwnership";

    public static final String FUNC_TRANSFER = "transfer";

    public static final String FUNC_TRANSFEROWNERSHIP = "transferOwnership";

    public static final String FUNC_UPDATESTATUS = "updateStatus";

    public static final String FUNC_VERSIONOF = "versionOf";

    public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred",
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}));
    ;

    public static final Event TRANSFER_EVENT = new Event("Transfer",
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>(true) {}, new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>(true) {}));
    ;

    public static final Event UPDATESTATUS_EVENT = new Event("UpdateStatus",
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>(true) {}, new TypeReference<Uint256>() {}));
    ;

    protected EvidencePreservation(String contractAddress, Client client,
                                   CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public static String getABI() {
        return ABI;
    }

    public List<OwnershipTransferredEventResponse> getOwnershipTransferredEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, transactionReceipt);
        ArrayList<OwnershipTransferredEventResponse> responses = new ArrayList<OwnershipTransferredEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
        ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            TransferEventResponse typedResponse = new TransferEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.evidenceId = (BigInteger) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.from = (byte[]) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.to = (byte[]) eventValues.getIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public List<UpdateStatusEventResponse> getUpdateStatusEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(UPDATESTATUS_EVENT, transactionReceipt);
        ArrayList<UpdateStatusEventResponse> responses = new ArrayList<UpdateStatusEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            UpdateStatusEventResponse typedResponse = new UpdateStatusEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.evidenceId = (BigInteger) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.status = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public BigInteger balanceOf(byte[] owner) throws ContractException {
        final Function function = new Function(FUNC_BALANCEOF,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger balanceOf(String owner) throws ContractException {
        final Function function = new Function(FUNC_BALANCEOF,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(toByteArray(owner))),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public TransactionReceipt create(byte[] owner, String org, BigInteger category, byte[] hash,
                                     String code, BigInteger status, String metadata) {
        final Function function = new Function(
                FUNC_CREATE,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(org),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(category),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(hash),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(code),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(status),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(metadata)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public TransactionReceipt create(String owner, String org, BigInteger category, String hash,
                                     String code, BigInteger status, String metadata) {
        final Function function = new Function(
                FUNC_CREATE,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(toByteArray(owner)),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(org),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(category),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(toByteArray(hash)),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(code),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(status),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(metadata)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public String getSignedTransactionForCreate(byte[] owner, String org, BigInteger category,
                                                byte[] hash, String code, BigInteger status, String metadata) {
        final Function function = new Function(
                FUNC_CREATE,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(org),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(category),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(hash),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(code),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(status),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(metadata)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return createSignedTransaction(function);
    }

    public String create(byte[] owner, String org, BigInteger category, byte[] hash, String code,
                         BigInteger status, String metadata, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_CREATE,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(org),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(category),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(hash),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(code),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(status),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String(metadata)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return asyncExecuteTransaction(function, callback);
    }

    public Tuple7<byte[], String, BigInteger, byte[], String, BigInteger, String> getCreateInput(
            TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_CREATE,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Bytes32>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = this.functionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple7<byte[], String, BigInteger, byte[], String, BigInteger, String>(

                (byte[]) results.get(0).getValue(),
                (String) results.get(1).getValue(),
                (BigInteger) results.get(2).getValue(),
                (byte[]) results.get(3).getValue(),
                (String) results.get(4).getValue(),
                (BigInteger) results.get(5).getValue(),
                (String) results.get(6).getValue()
        );
    }

    public Tuple1<BigInteger> getCreateOutput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getOutput();
        final Function function = new Function(FUNC_CREATE,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        List<Type> results = this.functionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple1<BigInteger>(

                (BigInteger) results.get(0).getValue()
        );
    }

    public String creatorOf(BigInteger evidenceId) throws ContractException {
        final Function function = new Function(FUNC_CREATOROF,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeCallWithSingleValueReturn(function, String.class);
    }

    public Tuple7<String, BigInteger, String, String, BigInteger, String, BigInteger> evidenceById(
            BigInteger evidenceId) throws ContractException {
        final Function function = new Function(FUNC_EVIDENCEBYID,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Bytes32>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple7<String, BigInteger, String, String, BigInteger, String, BigInteger>(
                (String) results.get(0).getValue(),
                (BigInteger) results.get(1).getValue(),
                toHexString((byte[]) results.get(2).getValue()),
                (String) results.get(3).getValue(),
                (BigInteger) results.get(4).getValue(),
                (String) results.get(5).getValue(),
                (BigInteger) results.get(6).getValue());
    }

    public BigInteger evidenceIdByIndex(byte[] owner, BigInteger index) throws ContractException {
        final Function function = new Function(FUNC_EVIDENCEIDBYINDEX,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(index)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger evidenceIdByIndex(String owner, BigInteger index) throws ContractException {
        final Function function = new Function(FUNC_EVIDENCEIDBYINDEX,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(toByteArray(owner)),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(index)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public TransactionReceipt initialize() {
        final Function function = new Function(
                FUNC_INITIALIZE,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public String getSignedTransactionForInitialize() {
        final Function function = new Function(
                FUNC_INITIALIZE,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList(), 0);
        return createSignedTransaction(function);
    }

    public String initialize(TransactionCallback callback) {
        final Function function = new Function(
                FUNC_INITIALIZE,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList(), 0);
        return asyncExecuteTransaction(function, callback);
    }

    public Boolean isOwnedBy(BigInteger evidenceId, byte[] owner) throws ContractException {
        final Function function = new Function(FUNC_ISOWNEDBY,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeCallWithSingleValueReturn(function, Boolean.class);
    }

    public String owner() throws ContractException {
        final Function function = new Function(FUNC_OWNER,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeCallWithSingleValueReturn(function, String.class);
    }

    public TransactionReceipt renounceOwnership() {
        final Function function = new Function(
                FUNC_RENOUNCEOWNERSHIP,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public String getSignedTransactionForRenounceOwnership() {
        final Function function = new Function(
                FUNC_RENOUNCEOWNERSHIP,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList(), 0);
        return createSignedTransaction(function);
    }

    public String renounceOwnership(TransactionCallback callback) {
        final Function function = new Function(
                FUNC_RENOUNCEOWNERSHIP,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList(), 0);
        return asyncExecuteTransaction(function, callback);
    }

    public TransactionReceipt transfer(BigInteger evidenceId, byte[] newOwner) {
        final Function function = new Function(
                FUNC_TRANSFER,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(newOwner)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public String getSignedTransactionForTransfer(BigInteger evidenceId, byte[] newOwner) {
        final Function function = new Function(
                FUNC_TRANSFER,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(newOwner)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return createSignedTransaction(function);
    }

    public String transfer(BigInteger evidenceId, byte[] newOwner, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_TRANSFER,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(newOwner)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return asyncExecuteTransaction(function, callback);
    }

    public Tuple2<BigInteger, byte[]> getTransferInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_TRANSFER,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Bytes32>() {}));
        List<Type> results = this.functionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<BigInteger, byte[]>(

                (BigInteger) results.get(0).getValue(),
                (byte[]) results.get(1).getValue()
        );
    }

    public TransactionReceipt transferOwnership(String newOwner) {
        final Function function = new Function(
                FUNC_TRANSFEROWNERSHIP,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.Address(newOwner)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public String getSignedTransactionForTransferOwnership(String newOwner) {
        final Function function = new Function(
                FUNC_TRANSFEROWNERSHIP,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.Address(newOwner)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return createSignedTransaction(function);
    }

    public String transferOwnership(String newOwner, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_TRANSFEROWNERSHIP,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.Address(newOwner)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return asyncExecuteTransaction(function, callback);
    }

    public Tuple1<String> getTransferOwnershipInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_TRANSFEROWNERSHIP,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        List<Type> results = this.functionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple1<String>(

                (String) results.get(0).getValue()
        );
    }

    public TransactionReceipt updateStatus(BigInteger evidenceId, BigInteger newStatus) {
        final Function function = new Function(
                FUNC_UPDATESTATUS,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(newStatus)),
                Collections.<TypeReference<?>>emptyList(), 4);
        return executeTransaction(function);
    }

    public String getSignedTransactionForUpdateStatus(BigInteger evidenceId, BigInteger newStatus) {
        final Function function = new Function(
                FUNC_UPDATESTATUS,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(newStatus)),
                Collections.<TypeReference<?>>emptyList(), 4);
        return createSignedTransaction(function);
    }

    public String updateStatus(BigInteger evidenceId, BigInteger newStatus,
                               TransactionCallback callback) {
        final Function function = new Function(
                FUNC_UPDATESTATUS,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(evidenceId),
                        new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Uint256(newStatus)),
                Collections.<TypeReference<?>>emptyList(), 4);
        return asyncExecuteTransaction(function, callback);
    }

    public Tuple2<BigInteger, BigInteger> getUpdateStatusInput(
            TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_UPDATESTATUS,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = this.functionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<BigInteger, BigInteger>(

                (BigInteger) results.get(0).getValue(),
                (BigInteger) results.get(1).getValue()
        );
    }

    public BigInteger versionOf(byte[] owner) throws ContractException {
        final Function function = new Function(FUNC_VERSIONOF,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(owner)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger versionOf(String owner) throws ContractException {
        final Function function = new Function(FUNC_VERSIONOF,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32(toByteArray(owner))),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public static EvidencePreservation load(String contractAddress, Client client,
                                            CryptoKeyPair credential) {
        if(credential == null){
            credential = new FakeCryptoKeyPair();
        }
        return new EvidencePreservation(contractAddress, client, credential);
    }

    public static EvidencePreservation deploy(Client client, CryptoKeyPair credential) throws
            ContractException {
        return deploy(EvidencePreservation.class, client, credential, getBinary(client.getCryptoSuite()), getABI(), null, null);
    }

    public static class OwnershipTransferredEventResponse {
        public TransactionReceipt.Logs log;

        public String previousOwner;

        public String newOwner;
    }

    public static class TransferEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger evidenceId;

        public byte[] from;

        public byte[] to;
    }

    public static class UpdateStatusEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger evidenceId;

        public BigInteger status;
    }

    public static byte[] toByteArray(String hexString) {
        if (StringUtils.isEmpty(hexString))
            return null;
        hexString = hexString.toLowerCase();
        final byte[] byteArray = new byte[hexString.length() >> 1];
        int index = 0;
        for (int i = 0; i < hexString.length(); i++) {
            if (index  > hexString.length() - 1)
                return byteArray;
            byte highDit = (byte) (Character.digit(hexString.charAt(index), 16) & 0xFF);
            byte lowDit = (byte) (Character.digit(hexString.charAt(index + 1), 16) & 0xFF);
            byteArray[i] = (byte) (highDit << 4 | lowDit);
            index += 2;
        }
        System.out.println("========"+byteArray);
        return byteArray;
    }


    /**
     * byte[] to Hex string.
     *
     * @param byteArray the byte array
     * @return the string
     */

    public static String toHexString(byte[] byteArray) {
        final StringBuilder hexString = new StringBuilder("");
        if (byteArray == null || byteArray.length <= 0)
            return null;
        for (int i = 0; i < byteArray.length; i++) {
            int v = byteArray[i] & 0xFF;
            String hv = Integer.toHexString(v);
            if (hv.length() < 2) {
                hexString.append(0);
            }
            hexString.append(hv);
        }
        return hexString.toString().toLowerCase();
    }

}
